/**
 * @author QL
 * @date 2021-12-24 13:57:42
 * @version V..
 * @description 接口控制方法，组装完整的接口url
 */
import GlobalVariable from './GlobalVariable.js'

class NetInterface extends GlobalVariable {
	constructor() {
		super()

		this.loginFace = '/ocn/getAccessToken'

		this.socketRoute = '/websocket/'

		this.testRequest = '/testRequest'

		this.testFileUpload = '/testFileUpload'
	}

	/**
	 * @author QL
	 * @date 2021-12-24 13:57:55
	 * @version V..
	 * @description get set 方法部分
	 */
	_getInterface(serverName, urlName) {
		try {
			if (this[urlName] === undefined) {
				throw new Error("未声明的api别名");
			} else {
				return this._getIPHOST(serverName) + this[urlName];
			}
		} catch (e) {
			this.utils.setConsole("api别名异常：" + "(" + urlName + ")", e);
			//TODO handle the exception
			if (urlName.indexOf('http') != -1) {
				return urlName;
			} else {
				return this._getIPHOST(serverName) + urlName;
			}
		}
	}
}

export default NetInterface
